package com.pulsarwebdevelopment.concordance;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ConcordanceOutputMap<K,V> extends ConcordanceOutput<K, V> {

	/**
	 * The backing map used by this object.
	 */
	private Map<K, List<V>> outputMap = new HashMap<K, List<V>>();
	
	@Override
	public void flush() {
		if(this.outputMap.containsKey(curKey)){
			List<V> tempMap = this.outputMap.get(curKey);
			tempMap.addAll(curValues);
			this.outputMap.put(curKey, tempMap);
		}else{
			this.outputMap.put(curKey, curValues);
		}
		
		this.curValues = new ArrayList<V>();
	}
	
	/**
	 * Get the map that is being used as a backing object.
	 * @return The backing Map.
	 */
	public Map<K,List<V>> getMap(){
		return this.outputMap;
	}

}
